<?
ob_start();
session_start();
include("../conf/config.php");
include("../conf/database.php");
include("../conf/tools.php");

$memberId=$_GET["mid"];
$mode=$_GET["mode"]; 
if($mode=="rp") //Remove Photo
{
$arrInfo_mem=Array();
$arrInfo_mem["photo_filename"]='';
update_qry("bkitc_profiles",$arrInfo_mem," registrant_id=".$memberId);
exit;

}

foreach($_POST as $key => $value) { $arr_data[$key]=$value;}

$arr_data["gender"]=$arr_data["rbGender"];
if($arr_data["reg_state"]=="Other") $arr_data["reg_state"]=$arr_data["reg_state_other"];
$arr_data["telephone_no"]=$arr_data["telephone_number"];
$arr_data["mobile_no"]=$arr_data["cell_number"];
$arr_data["alternate_email_id"]=$arr_data["alternate_email"];
$arr_data["email_id"]=$arr_data["email_address"];
$arr_data["technical_specifications"]=$arr_data["technical_specializations"];
$arr_data["rec_status"]="1";
$arr_data["reg_type"]=$arr_data["ddlRegType"];
if($arr_data["reg_type"]=="") $arr_data["reg_type"]="2";
if($arr_data["are_you_bk"]==0) $arr_data["aloukik_dob"]='';
$arr_data["years_it_exp"]=(int)$arr_data["years_it_exp_p1"].".".(int)$arr_data["years_it_exp_p2"];

foreach($arr_data as $key => $value) { $arr_data[$key]=addslashes($value); 

}

$target_path = "../images/photos/";
$actual_path=$target_path . $memberId . "/";
if(!is_dir($target_path)) mkdir($target_path);
if(!is_dir($actual_path)) mkdir($actual_path);

if($memberId>0)
{


	
$target_path = $target_path . basename( $_FILES['file_photo']['name']); 

if(move_uploaded_file($_FILES['file_photo']['tmp_name'],$actual_path.$_FILES['file_photo']['name'])) {

$arr_data["photo_filename"]=$_FILES['file_photo']['name'];
} 


update_qry("bkitc_profiles",$arr_data,"registrant_id=".$memberId);
qry_data("update bkitc_profiles set last_updated=now() where registrant_id=".$memberId);



}
else
{


	$memberId=insert_qry("bkitc_profiles",$arr_data);

	
	$toEmailId=$arr_data["email_id"];
	if($toEmailId!="") send_member_email($toEmailId,$memberId);

	

	$actual_path=$target_path . $memberId . "/";
	if(!is_dir($target_path)) mkdir($target_path);
	if(!is_dir($actual_path)) mkdir($actual_path);
	
	
	$target_path = $target_path . basename( $_FILES['file_photo']['name']); 

	$arrInfo=array();
	if(move_uploaded_file($_FILES['file_photo']['tmp_name'],$actual_path.$_FILES['file_photo']['name'])) {

		$arrInfo["photo_filename"]=$_FILES['file_photo']['name'];
		
		update_qry("bkitc_profiles",$arrInfo," registrant_id=".$memberId);

	} 

	qry_data("update bkitc_profiles set submission_date=now() where registrant_id=".$memberId);

}


$siglist=$_POST["chk"];

setMemberSIG($memberId,$siglist);

header("location:edit_member.php?mode=edit&mid=".$memberId);
?>



